<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
<title></title>
<%@ include file="/WEB-INF/jsp/common/inc.jsp" %>
<link rel="stylesheet" href="${_resources}bootstrap/bootstrap.min.css" />
<link rel="stylesheet" href="${_resources}bootstrap/bootstrap-table.min.css" />
<script type="text/javascript" src="${_resources}jquery-ui/jquery-ui-1.10.4.custom.min.js"></script>
<link rel="stylesheet" href="${_resources}jquery-ui/jquery-ui-1.10.4.custom.min.css" />
<link type="text/css" rel="stylesheet" href="${_resources}css/style.css">
<script  type="text/javascript">
	var projectNodeList;
	$(function (){
		projectNodeList = $("#projectNodeList").bootstrapTable({
              url : '${_baseUrl}/kdtrUplodeDocController/getKdProjectList?rand='+Math.random(),
              pagination: true,
              pageList: [5, 10, 20, 50],
              queryParams: queryParams,
              clickToSelect: false,
        	  singleSelect  : true,
              columns: [{
                   field: 'radio',
                   radio: true,
                   width: 35,
                   align: 'center',
                   title: '选择',
                   formatter : function(value, row, index){
                	   if (row.isPush == "0"){
                		   return {               	       
               	             checked : true//设置选中
               	           };
                	   }    
                   }
               },{
                   field: 'projectId',
                   title: 'projectId',
                   visible:false,
                   width: 5,
                   align: 'center'
               },{
                   field : 'projectname',
                   title : '项目名称',
                   width: 140,
                   align: 'center'
               },{
                   field : 'nodeCode',
                   title : '项目标识',
                   width: 80,
                   align: 'center'
               },{
                   field: 'projectPath',
                   title: '项目路径',
                   width: 200,
                   align: 'center'
              },{
                  field : 'projectManagerName',
                  title : '项目<br>负责人',
                  width: 70,
                  align: 'center'
               },{
                   field : 'projectstatus',
                   title : '项目状态',
                   width: 70,
                   align: 'center',
                   formatter: function(value, row, index){
                  	  var str ;
                       if(value == "1"){
                           str = "<span class='notCompiled'>未构建</span>";
                       }else if(value == "2"){
                           str = "<span class='compilation'>编制中</span>";
                       }else if(value == "3"){
                           str = "变更中";
                       }else if(value == "4"){
                           str = "<span class='alreadyPublished'>已归档</span>";
                       }
                       return str;
                   }
               },{
                   field : '',
                   title : '项目来源',
                   width: 70,
                   align: 'center',
                   formatter: function(value, row, index){
                   	  if(row.kpNodeId != null && row.kpNodeId != "0"){
                   		  return "所级项目";
                   	  }else{
                   		  return "部门自建项目"; 
                   	  }
                   }
                },{
                    field : 'documentCount',
                    title : '文档总数',
                    width: 70,
                    align: 'center'
                 }],
              onLoadSuccess : function(data) {
                  var cellIndex=parseInt($(".table_inline th").length);
                  $(".table_inline tr td").each(function(){
                      if(this.cellIndex != cellIndex){
                          $(this).attr("title",$(this).text());
                      }
                  });
              },
          });
		
		$("#proName").keydown(function(event) {//给输入框绑定按键事件
		    if(event.keyCode == "13") {//判断如果按下的是回车键则执行下面的代码
		    	refreshTable();
		  	}
		});

	});
	function queryParams(params){
        return {
            pageSize: params.limit,
            pageNo: params.pn,
            sort : params.sort,
            order : params.order,
            search : $("#proName").val(),
            kdProjectId : "${kdProjectId}"
       }
    }

	function refreshTable(){
		projectNodeList.bootstrapTable('refresh');
	}

	
	function cancel(){
		var index = parent.layer.getFrameIndex(window.name);
		parent.layer.close(index);
	}
	
	function nextStep(){
		var selected = projectNodeList.bootstrapTable('getSelections');
		if(selected.length == 0){
			layer.msg("请选择一个项目");
			return false;
		}
		
		cancel();
		
		layerIndex = parent.layer.open({
            type:2 //Page层类型
            ,area: ['850px', '350px']
            ,title: '文档列表'
            ,shade: 0.3 //遮罩透明度
            ,maxmin: true //允许全屏最小化
            ,anim:false  //0-6的动画形式，-1不开启
            ,content: '${_baseUrl}/kdtrUplodeDocController/showKdProjectDocList?kdProjectId='+selected[0].projectid+'&rand='+Math.random()
       }); 			  
	   parent.layer.full(layerIndex);
	}
	
	
	function gotoProjectBaseInfo(projectId){
		var path = "${_baseUrl}/project/gotoProjectBaseInfoView?projectId="+projectId+"&rand="+Math.random();
		layerIndex = layer.open({
            type:2 //Page层类型
            ,area: ['850px', '350px']
            ,title: '项目详细信息'
            ,shade: 0.3 //遮罩透明度
            ,maxmin: true //允许全屏最小化
            ,anim:false  //0-6的动画形式，-1不开启
            ,content: path
       }); 			  
	   layer.full(layerIndex);
	}
</script>
</head>
<style type="text/css">
.bootstrap-table{
width:100%;
}
</style>
<body> 
	<div class="main">
	    <div class="func_bar">
	        <div class="btn_container" style="margin: 4px 0 5px 0px;">
	  
	        </div>
	        <div class="func_search">
				<div class="func_search_div"></div>
		        <input type="text" name="proName" id="proName" value="" placeholder="请输入项目名称或标识" />
		        <a class="search_btn" id="search" href="javascript:;" onclick="refreshTable();"></a>
			</div>
	    </div>
		  <div style="overflow: auto; width:98%;margin: auto;">
	        <table id="projectNodeList" class="table table-bordered table_inline" >
	    	</table> 
    	</div>        
		<div class="important_Preservation">
		    <a href="javascript:void(0);" id="submit" onclick="nextStep()">下一步</a>
		    <a href="javascript:void(0);" id="cancel" onclick="cancel()">取 消</a>
		</div>
    </div>
</body>
</html>
